Learn about the Smarty template and view the documentation. if you have any questions about Block, click here at www. smarty. netdocszh... see the document: the output of the results in the document should be: {code ...} so I beg for answers...
Learn the Smarty template and view the documentation. if you have any questions about Block
Class
init.smarty.php
One: Define the use of functions and blocks in PHP files
mysmarty.php
Mysmarty.html
Two: Add a new file definition function and block in the Smarty Plugin folder plugins
mysmarty.php
Mysmarty.html
Under plugins in the Smarty Plugins folder:
function.hello.php (note naming rules)
block.world.php (note naming rules)
Template Inheritance (Content page Inherits master page): Implements code reuse.
Resolving code reuse issues:Scenario 1: Use include all (include the equivalent of copy and paste, which will form a large number of the same page, occupy bandwidth)Scenario 2: Full use of extends (recommended use of the scheme)Scenario 3: One using include, one using extends (not recommended)
Steps:The first step is to create a parent template for the child template to inherit, layout, and template layout.The se
Custom functionsfunction. Yanga. php page is called with plug-in formTemplate tpl.php PageBrowser outputI am Mr.yangI am Mr.yangI am Mr.yangI am Mr.yang AAAAAI am Mr.yang AAAAAI am Mr.yang AAAAA==========================================================Custom block functionsBlocks function Block pageTemplate tpl.php PageBrowser outputI AM block!I AM block!I AM block!==========================================================This article is from the "Jin Sha Harbor" blog, please be sure to keep thi
("newsArray", $ array );// Compile and display the index.htm template under./templates$ Smarty-> display ("example.htm ");?>
Output result: example. php:
The code is as follows:
Here an array is output:
News No.: 1
News: 1st News
News No.: 2
News: 2nd news
News No.: 3
News: 3rd News
News No.: 4
News: 4th News
News No.: 5
News: 5th News
News No.: 6
News: 6th news
Foreach can also use foreachelse to match and use foreachelse to indicate the operati
The code block in 4 in Java is summarized as follows:* Add static code block, write a pair of {} in the class to construct a block of code, in the method write a pair of {} is a common code block,* There is also a code block in Java that is a synchronous code block, commonly used in multi-threading, synchronized keyword,* Synchronization code block format is: synchronized (Synchronization object) {}* Static code blocks are executed before the construc
Smarty is chicken, smarty is chicken, smarty is chicken, Smarty is chicken ribs!
Play a title party, sorry, hope to come in people told me: you are wrong!
--Do not open the cache, light read compiled template, most of which is the echo output, performance improvement on the less do not do array loop
-If it's open, th
Tag: BER does not have to return an IMG action item to start www. Word ProofReprinted from: http://www.cnblogs.com/ysocean/p/8194428.htmlDirectory
1. Static code block
①, format
②, timing of execution
The role of ③, static code blocks
④, static code block cannot exist in any method body
⑤, static code blocks cannot access normal variables
2. Building cod
One: Ordinary code block1 //Ordinary code block: {} that appears in a method or statement is called a normal code block . ordinary blocks of code and general execution order of statements are determined by the order in which they appear in the code-"first Occurrence first" 2 Public classcodeblock01{3 Public Static voidMain (string[] args) {4 {5 int x=3; 6 System.out.println ("1, variable x= in normal code block" +x); 7 }
1. Common code Blockspublic static void Main (string[] args) {/* Common code block:* Direct definition of "{Normal Code Execution statement}" in a method or statement is called a normal code block.* Normal code block execution order is determined by the order in which they appear in the code--"first Occurrence first"* */{System.out.println ("This is normal code block a");}New A ();{System.out.println ("This is normal code block B");}}Execution result: Here is the normal code block aThis is norma
Common Code blocks in Java. Construct code blocks. Differences between static code blocks and code examples. java examples.
Execution sequence: (the priority ranges from high to low .) Static code block> mian method> constructor code block> constructor method.
The static code block is executed only once. The construction code block is executed every time an objec
Java constructs static code blocks for common code blocks and static code blocks.
1. Common Code Block
Public static void main (String [] args ){/* Common Code block:* A code block is directly defined as a normal code block when "{execution Statement of Common Code}" appears in a method or statement.* The execution sequence of common code
memory) because the JVM executes a static code block when the class is loaded, the static code block is executed before the main method. If a class contains more than one static block of code, it is executed following the code that is defined first, followed by the defined code.
Ps:
1 static code blocks cannot exist in any method body.
2 static code blocks cannot directly access static instance variable
rendering. But as a result, visual designers also have to learn how to use the template language. The operating principle of the template engine, first we look at the following diagram:The general template engine (such as Phplib) is in the creation of template objects to be resolved by the template, and then put the variable into, through the parse () this method to parse the template, and finally the page output.For Smarty users, the program does
This article describes how to get started with smarty in half an hour and analyzes the attributes, methods, and usage of smarty in the form of an instance, for more information about how to get started with smarty, see this article. Share it with you for your reference. The specific implementation method is as follows:
I. sm
-called block is probably like this:
Area content
Most of these blocks will be in the PHP program with if or for, while to control their display status, although the template looks more concise, but as long as a change in the display mode of different templates, PHP program is bound to change again!
In Smarty, everything is dominated by variables, and all the rendering logic allows the template to
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.